# -*- coding: UTF-8 -*-

import direct.directbase.DirectStart
import panda3d.core  as CORE
import direct.showbase.DirectObject as DO 
import game.elements.map.game_map as GMAP
import game.elements.role.player as GPLAYER 
import game.elements.role.monster as GMONSTER 
import game.elements.camera.game_camera as GCAM
import effects.lighting 
import game.elements.input.keyboard as GBOARD 
import game.actions.move as GMOVE
import game.actions.fight as GFIGHT
import game.elements.input.mouse as GMOUSE
# 游戏场景边界
class GameMain:
    def __init__(self,game_obj):
        self.game = game_obj
        return 
    
    def GameInit(self):
        base.win.setClearColor(CORE.Vec4(1,1,1,1))
        self.pmap = GMAP.GameMap()
        self.pmap.initMap()
        
        startPos = self.pmap.game_map.find("**/start_point").getPos()
        self.player = GPLAYER.Player(self.game,startPos)
        self.player.initPlayer()
        
        startPos1 = CORE.Point3(-101.5, -9.92551, -0.688843)
        self.monster = GMONSTER.Monster(self.game,startPos1)
        self.monster.initMonster()
        
        self.cam =GCAM.GameCamera(self.game,self.player)
        self.cam.initCamera( )
        
        self.keybord = GBOARD.KeyBoard(self.game)
        self.keybord.initKeyBoard()
        
        self.mouse = GMOUSE.Mouse(self.game,self.player)
        self.mouse.initMouse()
        self.mouse.makePickable(self.monster.ralph)
        
        self.move = GMOVE.Move(self.cam,self.game,self.player)
        self.move.initMove()
        
        self.fight = GFIGHT.Fight(self.cam,self.game,self.player)
        self.fight.initFight()
        
        effects.lighting.Lighting.SetLight1()
        return
    def GameRun(self,task):
        self.move.runMove( )
        self.fight.runFight(self.player,self.monster)
        self.monster.MonsterMove(task)
        return task.cont

 
